<?php
/**
 * Created by JetBrains PhpStorm.
 * User: cgp
 * Date: 13-6-20
 * Time: 下午2:33
 * 实例化SOAP
 */

class SoapInit {
    /**
     * 票付通内部接口实例
     *
     * @var $soapi
     */
    private static $soapi;
    /**
     * 保存16u内部接口实例
     *
     * @var $soapFX
     */
    private static $soapFX;
    /**
     * 票付通外部接口实例
     * @var null
     */
    private static $soap_wsdl=null;

    /**
     * 内部接口实例化
     *
     * @return SoapClient
     */
    static function GetSoapInside()
    {
        if(!empty(self::$soapi)) {
            return self::$soapi;
        }
        $ac = !empty($GLOBALS['_ac']) ? $GLOBALS['_ac'] : '16ucom';
        $pw = !empty($GLOBALS['_pw']) ? $GLOBALS['_pw'] : 'c33367701511b4f6020ec61ded352059';
        self::$soapi = new SoapClient(null,array(
            "location" => "http://localhost/open/openService/pft_insideMX.php",
            "uri" => "www.16u.com?ac_16u={$ac}|pw_16u={$pw}|auth_16u=true"));
        return self::$soapi;
    }

    /**
     * 16u分销平台内部接口实例
     *
     * @return SoapClient
     */
    static function GetSoapFX()
    {
        if(!empty(self::$soapFX)) {
            return self::$soapFX;
        }
        self::$soapFX = new SoapClient(null,array(
            "location" => "http://open.16u.com/openService/s_insideMX.php",
            "uri" => "www.16u.com?ac_16u={$GLOBALS['_ac']}|pw_16u={$GLOBALS['_pw']}|auth_16u=true"));
        return self::$soapFX;
    }

    /**
     * 票付通外部接口实例（wsdl版本）
     *
     * @return null|SoapClient
     */
    static function GetSoapWsdl()
    {
        if(!empty(self::$soap_wsdl)) {
            return self::$soap_wsdl;
        }
        self::$soap_wsdl = new SoapClient('http://open.12301.cc/openService/MXSE.wsdl',
            array('encoding' =>'UTF-8','cache_wsdl' => 0));
        return self::$soap_wsdl;
    }
}